/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sv.com.dizucar.modelo;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author 43579648
 */
@Entity
@Table(name = "DETALLE_VENTA", catalog = "", schema = "DIZUCAR")
@NamedQueries({
    @NamedQuery(name = "DetalleVenta.findAll", query = "SELECT d FROM DetalleVenta d"),
    @NamedQuery(name = "DetalleVenta.findByIddetalleventa", query = "SELECT d FROM DetalleVenta d WHERE d.iddetalleventa = :iddetalleventa"),
    @NamedQuery(name = "DetalleVenta.findByCantidad", query = "SELECT d FROM DetalleVenta d WHERE d.cantidad = :cantidad")})
public class DetalleVenta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "IDDETALLEVENTA", nullable = false)
    private Integer iddetalleventa;
    @Basic(optional = false)
    @Column(name = "CANTIDAD", nullable = false, precision = 9, scale = 0)
    private BigDecimal cantidad;
    @Basic(optional = false)
    @Column(name = "PRECIOUNITARIO", nullable = false, precision = 9, scale = 2)
    private BigDecimal precioUnitario;
    @JoinColumn(name = "IDVENTA", referencedColumnName = "IDVENTA", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Venta venta;
    @JoinColumn(name = "IDPRODUCTOPRESENTACION", referencedColumnName = "IDPRODUCTOPRESENTACION", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private ProductoPresentacion productoPresentacion;
    @JoinColumn(name = "IDMARCA", referencedColumnName = "IDMARCA", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Marca marca;

    public DetalleVenta() {
    }

    public DetalleVenta(Integer iddetalleventa) {
        this.iddetalleventa = iddetalleventa;
    }

    public DetalleVenta(Integer iddetalleventa, BigDecimal cantidad) {
        this.iddetalleventa = iddetalleventa;
        this.cantidad = cantidad;
    }

    public Integer getIddetalleventa() {
        return iddetalleventa;
    }

    public void setIddetalleventa(Integer iddetalleventa) {
        this.iddetalleventa = iddetalleventa;
    }

    public BigDecimal getCantidad() {
        return cantidad;
    }

    public void setCantidad(BigDecimal cantidad) {
        this.cantidad = cantidad;
    }

    public Venta getVenta() {
        return venta;
    }

    public void setVenta(Venta venta) {
        this.venta = venta;
    }

    public ProductoPresentacion getProductoPresentacion() {
        return productoPresentacion;
    }

    public void setProductoPresentacion(ProductoPresentacion productoPresentacion) {
        this.productoPresentacion = productoPresentacion;
    }

    public Marca getMarca() {
        return marca;
    }

    public void setMarca(Marca marca) {
        this.marca = marca;
    }

    public BigDecimal getPrecioUnitario() {
        return precioUnitario;
    }

    public void setPrecioUnitario(BigDecimal precioUnitario) {
        this.precioUnitario = precioUnitario;
    }

    
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iddetalleventa != null ? iddetalleventa.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetalleVenta)) {
            return false;
        }
        DetalleVenta other = (DetalleVenta) object;
        if ((this.iddetalleventa == null && other.iddetalleventa != null) || (this.iddetalleventa != null && !this.iddetalleventa.equals(other.iddetalleventa))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sv.com.dizucar.modelo.DetalleVenta[iddetalleventa=" + iddetalleventa + "]";
    }

}
